<#-- @ftlvariable name="entity" type="com.xci.platform.auth.entity.ContentEntity" -->
<#include "/_inc/_layout.ftl">
<@header/>
<div class="jxpanel" title="${entity.name}">
<div class="jxform-wrap" style="width: 80%;">
    <div class="jxform-container">
        <form id="editform" class="jxform" method="post" action="<@html.url "/auth/content/edit-save"/>">
            <input name="id" value="${entity.id!}" type="hidden">
            <input id="contentFormat" name="contentFormat" value="${entity.contentFormat!}" type="hidden">
            <textarea id="contentValue" name="contentValue" style="display: none">${entity.contentValue!}</textarea>
            <table class="table jxtable-form" style="width: 97%;margin-top: 0;">
                <tr>
                    <td colspan="6">
                        <div class="jxtabs jxtabs-line" style="margin-left: 30px;">
                            <ul class="nav nav-tabs">
                                <li>
                                    <a href="#tab-content" data-toggle="tab" data-format="1">HTML</a>
                                </li>
                                <li>
                                    <a href="#tab-content" data-toggle="tab" data-format="2">文本</a>
                                </li>
                            </ul>
                            <div class="tab-content">
                                <div id="tab-content" class="tab-pane jx-overflow-auto fade in active">
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
            <div class="jxform-footer" style="padding-left: 30px;">
                <button id="btnSave" class="btn btn-primary" type="button">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
</div>
</div>
<@footer>
    <@html.ueScript/>
    <script src="<@html.url '/auth/js/util/switch-html-text-editor.js'/>"></script>
    <script>
        $('form').on('beforesubmit', function () {
            $('#contentFormat').val(jx.switchHtmlTextEditor.getFormat());
            $('#contentValue').val(jx.switchHtmlTextEditor.getContent());
        });
        jx.ready(function () {
            var htmlOps = {
                initialFrameWidth: '100%',
                initialFrameHeight: 300,
                serverUrl: '<@html.ueditorServerUrl/>'
            };
            var textOps = {
                width: '100%',
                height: '355px',
                cls: 'form-control'
            };
            jx.switchHtmlTextEditor.init($('.jxtabs'), $('#contentValue'),$('#contentFormat').val(), htmlOps, textOps);
        });

        $('#btnSave').click(function () {
            $('#editform').jxform().submit();
        });
        $('#editform').onFormSuccess(function (e, result) {
            jx.alert('保存成功');
        });
    </script>
</@footer>